Choices

Description

Specify one or more options to display in the CheckBox control.

Discussion

The Choices property lets you define the choices that will appear next to each checkbox. Clicking the button next to Choices will open the Define Choices dialog. There are three options for how to define the choices presented, Static, Dynamic, and Variable.

Defining Static Choices

In this scenario you can manually enter the choices to show for the CheckBox control.

  1. Click the smart field button for the Choices property to open the Define Choices dialog for a new or existing CheckBox control.

    images/static4.png
  2. The Define Choices dialog will open. Check the "Static" radio control.

    images/static2.png
  3. Define a list of choices for the control. Separate each choice by placing it on a new line.

    images/static3.png
  4. Run the component in Live Preview.

    images/static.png
    If the control appears to be wrapping reopen the Controls page, highlight the checkbox control, and adjust the Width or Height settings under the Field Properties section of the Control Properties list.

Dynamic Choices

The Dynamic option can be used to populate the control from a data source using an AlphaDAO connection. This is done as follows:

  1. Click the smart field button for the Choices property to open the Define Choices dialog for a new or existing CheckBox control.

  2. The Define Choices dialog will open. Select the Dynamic option.

    images/dyn.png
  3. Under the Data Source section of the Define choices dialog click the dropdown next to the "Data source type" property. Select AlphaDAO.

    images/dyn1.png
  4. Click the button next to the AlphaDAO Connection string name.

    images/dyn2.png
  5. Choose "Use a names connection string" and click the Select button. Connect to the Northwind database and click OK and OK again.

    images/dyn3.png
  6. Click the button next to the AlphaDAO SQL SELECT statement.

    images/dyn4.png
  7. Click the Select button. Choose the Customers table from the list of tables and click OK.

    images/dyn5.png
  8. Select the Countries field as the Field to display. Click OK and OK again.

    images/dyn6.png
  9. Run the component in Live Preview.

    images/dyn7.png

Variable Choices

An Xbasic variable can also be used to populate the CheckBox control. The variable can be statically defined or dynamically computed using data from a web server, Node service, or other means. The Xbasic variable is defined in the server-side events for the component. The steps below describe how to create a variable and use it to populate a CheckBox control:

  1. Open the UX Builder and then open the Events Server-side page.

    images/var.png
  2. In the Server-Side Events menu highlight the "onDialogInitialize"" event.

    images/var1.png
  3. Add the following code to the onDialog Initialize event:

    e.rtc.variableCheckBox = <<%str%
    one
    two
    three
    %str%
    images/var2.png
    Here we are defining a variable named "variableCheckBox" and populating the list of choices as one, two, and three.
  4. Click the smart field button for the Choices property to open the Define Choices dialog for a new or existing CheckBox control.

    images/var4.png
  5. The Define Choices dialog will open. From the "Choices are:" menu select 'Variable'.

    images/var5.png
  6. Enter 'variableCheckBox' as the variable name and click OK.

    images/var6.png
  7. Now go to Live Preview and run the component. You should see the list you defined appear as checkbox choices.

    images/varres.png